package _01Collection接口;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;

/*

 boolean add(E e) 
          确锟斤拷锟斤拷 collection 锟斤拷锟斤拷指锟斤拷锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
 boolean addAll(Collection<? extends E> c) 
          锟斤拷指锟斤拷 collection 锟叫碉拷锟斤拷锟斤拷元锟截讹拷锟斤拷拥锟斤拷锟� collection 锟叫ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
 void clear() 
          锟狡筹拷锟斤拷 collection 锟叫碉拷锟斤拷锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
 boolean contains(Object o) 
          锟斤拷锟斤拷锟� collection 锟斤拷锟斤拷指锟斤拷锟斤拷元锟截ｏ拷锟津返伙拷 true锟斤拷 
 boolean containsAll(Collection<?> c) 
          锟斤拷锟斤拷锟� collection 锟斤拷锟斤拷指锟斤拷 collection 锟叫碉拷锟斤拷锟斤拷元锟截ｏ拷锟津返伙拷 true锟斤拷 
 boolean equals(Object o) 
          锟饺较达拷 collection 锟斤拷指锟斤拷锟斤拷锟斤拷锟角凤拷锟斤拷取锟� 
 int hashCode() 
          锟斤拷锟截达拷 collection 锟侥癸拷希锟斤拷值锟斤拷 
 boolean isEmpty() 
          锟斤拷锟斤拷锟� collection 锟斤拷锟斤拷锟斤拷元锟截ｏ拷锟津返伙拷 true锟斤拷 
 Iterator<E> iterator() 
          锟斤拷锟斤拷锟节达拷 collection 锟斤拷元锟斤拷锟较斤拷锟叫碉拷锟斤拷锟侥碉拷锟斤拷锟斤拷锟斤拷 
 boolean remove(Object o) 
          锟接达拷 collection 锟斤拷锟狡筹拷指锟斤拷元锟截的碉拷锟斤拷实锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷诘幕锟斤拷锟斤拷锟窖★拷锟斤拷锟斤拷锟斤拷锟� 
 boolean removeAll(Collection<?> c) 
          锟狡筹拷锟斤拷 collection 锟斤拷锟斤拷些也锟斤拷锟斤拷锟斤拷指锟斤拷 collection 锟叫碉拷锟斤拷锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
 boolean retainAll(Collection<?> c) 
          锟斤拷锟斤拷锟斤拷锟斤拷 collection 锟斤拷锟斤拷些也锟斤拷锟斤拷锟斤拷指锟斤拷 collection 锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
 int size() 
          锟斤拷锟截达拷 collection 锟叫碉拷元锟斤拷锟斤拷锟斤拷 
 Object[] toArray() 
          锟斤拷锟截帮拷锟斤拷锟斤拷 collection 锟斤拷锟斤拷锟斤拷元锟截碉拷锟斤拷锟介。 
<T> T[] 
 toArray(T[] a) 
          锟斤拷锟截帮拷锟斤拷锟斤拷 collection 锟斤拷锟斤拷锟斤拷元锟截碉拷锟斤拷锟介；锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟街革拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷时锟斤拷锟斤拷锟斤拷同锟斤拷 

 * */
public class CollectionDemo {

    public static void main(String[] args) {
//		Collection c1 = new Collection(); 锟斤拷锟斤拷

        Collection c1 = new ArrayList();
        c1.add(1);
        c1.add("锟斤拷锟斤拷");
        c1.add('6');
        System.out.println(c1);

        Collection c2 = new LinkedList();
        c2.add("锟斤拷锟斤拷");
        c2.add("锟斤拷锟斤拷");
        c2.add("锟斤拷锟斤拷");
        System.out.println(c2);


        // 锟斤拷锟斤拷<>
        // 只锟杰存储<>锟斤拷锟狡讹拷锟斤拷锟酵碉拷锟斤拷锟斤拷
        Collection<String> collection = new ArrayList<>();
        collection.add("锟斤拷锟斤拷");
//		collection.add(1); 锟斤拷锟斤拷


        Collection c5 = new ArrayList();
        c5.add(c1);
        c5.add(c2);
        System.out.println(c5);


        // 锟狡筹拷 remove
//		 boolean remove(Object o) 
//       	锟接达拷 collection 锟斤拷锟狡筹拷指锟斤拷元锟截的碉拷锟斤拷实锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷诘幕锟斤拷锟斤拷锟窖★拷锟斤拷锟斤拷锟斤拷锟� 
//       boolean removeAll(Collection<?> c) 
//       	锟狡筹拷锟斤拷 collection 锟斤拷锟斤拷些也锟斤拷锟斤拷锟斤拷指锟斤拷 collection 锟叫碉拷锟斤拷锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷

        c2.remove("锟斤拷锟斤拷");
        System.out.println(c2);

        c2.add("锟斤拷锟斤拷");
        System.out.println(c2);
        c2.removeAll(c1);
        System.out.println(c2);

        //锟斤拷锟斤拷 retainAll
//		 boolean retainAll(Collection<?> c) 
//       	锟斤拷锟斤拷锟斤拷锟斤拷 collection 锟斤拷锟斤拷些也锟斤拷锟斤拷锟斤拷指锟斤拷 collection 锟斤拷元锟截ｏ拷锟斤拷选锟斤拷锟斤拷锟斤拷锟斤拷 
        Collection<String> c6 = new ArrayList<>();
        c6.add("锟斤拷锟斤拷");
        c6.add("锟斤拷斯");
        c6.add("锟斤拷斯");
        c6.add("锟斤拷锟斤拷");
        c6.add("锟斤拷锟斤拷");

        Collection<String> c7 = new ArrayList<>();
        c7.add("锟斤拷锟斤拷");
        c7.add("锟斤拷锟斤拷");
        c7.add("锟斤拷锟斤拷");
        c7.add("锟杰诧拷");

        c6.retainAll(c7);
        System.out.println("retainAll锟斤拷" + c6);

        //锟斤拷小锟斤拷锟斤拷  size
        System.out.println("锟斤拷小:" + c7.size());

        //锟斤拷锟� clear
        c6.clear();
        System.out.println("锟斤拷小锟斤拷" + c6.size());

        //转为锟斤拷锟斤拷
        Object[] str = c7.toArray();
        System.out.println(Arrays.toString(str));
    }

}
